/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TestUnits;

/**
 *
 * @author user1
 */
import javax.microedition.lcdui.*;
public class HolaCanvas extends Canvas implements CommandListener {
    private HolaMundo midlet;
    private Command salir;
    
    
    
public HolaCanvas(HolaMundo mid){
    salir = new Command("Salir", Command.EXIT,1);
    this.midlet = mid;
    this.addCommand(salir);
    this.setCommandListener(this);
    
}
public void paint(Graphics g) {
    g.setColor(0,155,255);
    g.fillRect(0,0,getWidth(),getHeight());
    g.setColor(0,255,0);
    int w = getWidth();
    int h = getHeight();

    g.drawString("Altura: "+h+" Ancho: "+w, (getWidth()/2), (getHeight()/2),
    Graphics.BASELINE|Graphics.HCENTER);
    g.drawLine(3,3,50,50);
    g.drawRect(3,120,20,20);
    g.fillRect(3,120,20,20);
    g.drawRoundRect(30,120,20,20,5,5);
    g.fillRoundRect(30,120,20,20,5,5);
    g.drawArc(1,170,getWidth()-1,getHeight()-1,0,270);
    g.fillArc(1,170,getWidth()-1,getHeight()-1,90,290);
    
    
}
public void commandAction(Command c, Displayable d){
    if (c == salir){
    midlet.salir();
}
}
}    
